package com.stx.blog.action;

import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.stx.blog.exception.BlogException;
import com.stx.blog.service.UserService;
import com.stx.blog.vo.UserVo;

public class UserAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = -3005415532143140893L;
	
	private UserVo uv=null;
	private UserService us;
	private String passwords=null;
	
	public String getPasswords() {
		return passwords;
	}

	public void setPasswords(String passwords) {
		this.passwords = passwords;
	}


	
	public UserVo getUv() {
		return uv;
	}

	public void setUv(UserVo uv) {
		this.uv = uv;
	}
	
	public UserService getUs() {
		return us;
	}

	public void setUs(UserService us) {
		this.us = us;
	}

	//添加注册用户
	public String addUser(){
		try {
			uv.setBlogCreatetime(new Date());
			uv.setBlogLastmodifytime(new Date());
			us.addUser(uv);
		} catch (BlogException e) {
			addActionError("该博客名已存在，请重新输入");
			return "input";
		} catch (Exception e) {
			e.printStackTrace();
			addActionError("此邮箱已经注册过");
			return "input";
		}
		return "success";
	}
	
}
